﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using WooCoo.Portal.Contracts;

namespace WooCoo.Portal.Data
{
    /// <summary>
    /// CreateDatabaseIfNotExists,DropCreateDatabaseAlways
    /// </summary>
    public class WooCooSeedData : CreateDatabaseIfNotExists<SupportDbContext>
    {
        protected override void Seed(SupportDbContext context)
        {
            context.SysUser.Add(new SysUser()
            {
                UserCode = "Admin",
                UserName = "系统管理员",
                Password = "woocoo",
                CreateBy = "Admin",
                CreateDate = DateTime.Now,
                State = "1"                
            });
            InitResource(context);
            base.Seed(context);
        }

        private void InitResource(SupportDbContext context)
        {
            #region 系统管理
            context.SysResource.Add(new SysResource()
            {
                ID = 1,
                ResName = "系统管理",
                HasChild = true,
                IDPath = "1",
                ResUrl = "",
                IconUrl = "",
                SortIndex = 1,
                SortIndexPath = "1",
                IsEnable = true,
                Level =1
            });
            context.SysResource.Add(new SysResource()
                {
                    ID = 2,
                    ResName = "资源管理",
                    ParentID = 1,
                    HasChild = false,
                    IDPath = "1/2",
                    ResUrl = @"Support/Resource/Index",
                    IconUrl = "glyphicon glyphicon-user",
                    SortIndex = 1,
                    SortIndexPath = "1/1",
                    IsEnable = true,
                    Level = 2

                });
            context.SysResource.Add(new SysResource()
            {
                ID = 3,
                ResName = "用户管理",
                ParentID = 1,
                HasChild = false,
                IDPath = "1/3",
                ResUrl = @"Support/Employee/Index",
                IconUrl = "glyphicon glyphicon-user",
                SortIndex = 2,
                SortIndexPath = "1/2",
                IsEnable = true,
                Level =2
            });
            context.SysResource.Add(new SysResource()
            {
                ID = 4,
                ResName = "角色管理",
                ParentID = 1,
                HasChild = false,
                IDPath = "1/4",
                ResUrl = @"Support/Role/Index",
                IconUrl = "glyphicon glyphicon-user",
                SortIndex = 3,
                SortIndexPath = "1/3",
                IsEnable = true,
                Level=2
            });
            #endregion

            #region 参数管理

            #endregion
        }
    }
}
